***********ERROR - FACTOR VARIABLES NOT ALLOWED 

use "$data\analysisdata.dta", clear
log using "$results\Table2", replace
encode string_strata, generate(stratalottery)

*globals
global controlwoman mbase_ageyears  fdstotal rantime ranerror numberkids
global controlhh land members adults mbase_electrified  mbase_OB mbase_scheduled

* restrict sample
keep if ITTanalysis~=.
keep if round=="baseline"


sort learnerid
merge learnerid using "$data\keep_woman.dta"
tab keep_woman

keep if keep_woman==1
 
bysort HHID learnerid: gen sequence=_n

foreach x of varlist $controlwoman {
bysort ITTanalysis: su `x' if sequence==1 & `x'!=.
regress `x' ITTanalysis i.strata if sequence==1 & `x'!=., robust
 }
 
 foreach x of varlist $controlhh {
bysort ITTanalysis: su `x' if sequence==1 & `x'!=.
regress `x' ITTanalysis i.strata if sequence==1 & `x'!=., robust
 }
log close
 exit 









